
package com.putao.album.main.url;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;

public class SlidingMenu extends RelativeLayout {
    private SlidingView mSlidingView;
    private View mMenuView;
    private View mDetailView;

    public SlidingMenu(Context context) {
        super(context);
    }

    public SlidingMenu(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void addViews(View left, View center, View right) {
        setLeftView(left);
        setRightView(right);
        setCenterView(center);
    }

    public void setLeftView(View view) {
        LayoutParams behindParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
        addView(view, behindParams);
        mMenuView = view;
    }

    public void setRightView(View view) {
        LayoutParams behindParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
        behindParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        addView(view, behindParams);
        mDetailView = view;
    }

    public void setCenterView(View view) {
        LayoutParams aboveParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        mSlidingView = new SlidingView(getContext());
        addView(mSlidingView, aboveParams);
        mSlidingView.setView(view);
        mSlidingView.invalidate();
        mSlidingView.setMenuView(mMenuView);
        mSlidingView.setDetailView(mDetailView);
    }

    public void setToggleListener(ToggleListener toggleListener) {
        mSlidingView.setToggleListener(toggleListener);
    }

    public void showLeftView(boolean bShow) {
        mSlidingView.showLeftView(bShow);
    }

    public void showRightView() {
        mSlidingView.showRightView();
    }
}
